

package top.continew.admin.controller.question;

import org.springframework.web.bind.annotation.*;
import top.continew.admin.question.manger.service.model.DelQuery;
import top.continew.admin.question.manger.service.WorkService;
import top.continew.starter.web.model.R;

@RestController
@RequestMapping("work")
public class WorkController {
    private WorkService workService;

    public WorkController(WorkService workService) {
        this.workService = workService;
    }

    @PostMapping("/{workTemplateId}/question")
    public R addWork(@PathVariable Long workTemplateId,
                     @RequestParam Long questionId,
                     @RequestParam Double score) throws Exception {
        workService.addWork(workTemplateId, questionId, score);
        return R.ok();
    }

    @GetMapping("/{workTemplateId}/question")
    public R getWorkScore(@PathVariable Long workTemplateId, @RequestParam Long questionId) throws Exception {
        return R.ok(workService.getWorkScore(workTemplateId, questionId));
    }

    @DeleteMapping
    public R del(@RequestBody DelQuery delQuery) throws Exception {
        this.workService.delQuestion(delQuery);
        return R.ok();
    }
}
